package com.eastfair.builder.service.impl;

import com.eastfair.builder.service.BuilderReportSpaceAuditService;
import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.home.api.ReportSpaceAuditFeign;
import com.eastfair.home.dto.ReportSpaceAuditDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 主场报馆审核服务.
 *
 * @author dqq
 * @date 2022 /8/9
 */
@Service
@Slf4j
public class BuilderReportSpaceAuditServiceImpl implements BuilderReportSpaceAuditService {

    @Resource
    private ReportSpaceAuditFeign reportSpaceAuditFeign;

    @Override
    public boolean submitReportSpaceAudit(ReportSpaceAuditDTO reportSpaceAuditDTO) {
        log.info("submitReportSpaceAudit - 调用主场提交报馆, reportSpaceAuditDTO={}", reportSpaceAuditDTO);
        R<Boolean> result = reportSpaceAuditFeign.submitReportSpaceAudit(reportSpaceAuditDTO);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result.getData();
    }

    @Override
    public boolean cancelSubmit(Long reportSpaceId) {
        log.info("cancelSubmit - 调用主场取消报馆, reportSpaceId={}", reportSpaceId);
        R<Boolean> result = reportSpaceAuditFeign.cancelSubmit(reportSpaceId);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result.getData();
    }
}